import request from '@/utils/request';

/**
 * 个人信息初始化
 */
export function baseInfoInit() {
  return request({
    url:  '/merchant_backend/profile/basic',
    method: 'GET'
  })
}

/**
 * 验证管理员密码
 * @param {Object} data 密码
 */
export function validPassword(data) {
  return request({
    url: '/merchant_backend/profile/validate_old_pwd',
    method: 'POST',
    data
  })
}

/**
 * 支付通道信息
 */
export function baseInfoChannel() {
  return request({
    url:  '/merchant_backend/profile/pay_channel',
    method: 'GET'
  })
}

/**
 * 获取银行名称列表
 */
export function GetBankName() {
  return request({
    url: '/merchant_backend/bankname',
    method: 'GET'
  })
}

/**
 * 证件类型
 * @param {Number} id_type 对公/对私
 */
export function GetIdType(id_type) {
  return request({
    url: '/merchant_backend/typeCertificates',
    method: 'GET',
    params: { id_type }
  })
}

/**
 * 支行名称搜索
 * @param {String} bank 银行代码
 * @param {String} bankname 搜索关键字
 */
export function GetSubBankName(bankname) {
  return request({
    url: '/merchant_backend/bankBranch',
    method: 'GET',
    params: { bankname }
  })
}

/**
 * 商户绑卡提交
 * @param {Number} id 商户id
 * @param {Object} date 提交参数
 */
export function BindBankSubMit(id, date) {
  const data = {
    id,
    bank_category: date.BankType,
    public_private: date.bank_type,
    id_type: date.id_type,
    number: date.number,
    bank_number: date.bank_number,
    account_name: date.name,
    sub_bank: date.sub_bank,
    bank_account: date.bank_name,
    contact_phone: date.phone,
    authentication_status: date.ValidType
  }
  return request({
    url: 'merchant_backend/witnessBank',
    method: 'POST',
    data
  })
}

/**
 * 银行卡解绑
 * @param {Number} id 商户id
 */
export function removeBindBank(id) {
  return request({
    url: 'merchant_backend/witnessUnbindBank',
    method: 'PUT',
    params: { id }
  })
}

/**
 * 商户绑卡初始化
 * @param {Number} id 登陆者id
 */
export function GetInit(id) {
  return request({
    url: '/merchant_backend/witnessBank',
    method: 'GET',
    params: { id }
  })
}

/**
 * 鉴权短信验证
 * @param {Number} id 商户id
 * @param {Number} message_code 验证码
 */
export function validCodeSubMit(id, message_code) {
  const data = {
    id,
    message_code
  }
  return request({
    url: '/merchant_backend/witnessBindVerifyMessage',
    method: 'POST',
    data
  })
}

/**
 * 鉴权金额验证
 * @param {Number} id 商户id
 * @param {Number} money 打款金额
 */
export function validMoneySubMit(id, money) {
  const data = {
    id,
    money
  }
  return request({
    url: '/merchant_backend/witnessBindVerifyMoney',
    method: 'POST',
    data
  })
}

/**
 * 
 * @param {Number} merchant_id 商户ID
 * @param {Number} code 协议标示
 */
export function handClickPactInfo(merchant_id, code) {
  return request({
    url: '/merchant_backend/agreementQuery',
    method: 'GET',
    params: { merchant_id, code }
  })
}
